<script setup>
import CompE from '@/views/CompE.vue';

defineProps({
  msg: {
    type: String,
    required: true
  },
  name: String
})

/**
 * 子组件向父组件传递数据
 */
var age = ref(18)
const emits = defineEmits(['e-age','e-hobby']) // 自定义事件

const sendData = () => {
  emits('e-age', age.value) // 触发事件，传递数据
}

</script>

<template>
  <h1>{{ msg }}, {{ name }}</h1>
  <button @click="sendData">触发自定义事件，向父组件传递数据</button>
  <hr>

  <CompE></CompE>
</template>

<style scoped>

</style>
